import java.util.Arrays;
import java.util.Scanner;

public class test4{
	public static void main(String[] args)
	{
		System.out.println("Please input array length :");
		Scanner sc = new Scanner(System.in);
		int arrLength=sc.nextInt();

		test4 Extend = new test4();

		int[] a = new int[arrLength];
		System.out.println("Please input array number :");
		for(int i=0;i<arrLength;i++)
		{
			int tmp = sc.nextInt();
			a[i]=tmp;

			arrLength=Extend.ArrExtend(a).length;
			a=Extend.ArrExtend(a);
		}

	}

	public int[] ArrExtend(int[] arr)
	{
		int i;

		for(i = arr.length-1;i>=0;i--)
		{
			if(0!=arr[i])
			{
				break;
			}
		}

		if(i+1>=arr.length*0.8)
		{
			double num = arr.length*1.5;
			int[] arr1 = new int[(int)num];
			System.arraycopy(arr, 0, arr1, 0, i+1);

			System.out.println("The array length after extend : " + arr1.length);
			System.out.println("The array after extend : " + Arrays.toString(arr1));
			return arr1;
		}

		return arr;
	}
}